home *** CD-ROM | disk | FTP | other *** search
- // the implementation of class CKBANToolBar
- // Copyright (C) 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
-
- #include "stdafx.h"
-
- #include "kbandoc.h"
- #include "kbanview.h"
- #include "resource.h"
-
- #include "kbantbar.h"
-
- BEGIN_MESSAGE_MAP(CKBANToolBar, CToolBar)
- ON_WM_CREATE()
- ON_CBN_SELENDOK(IDC_LAYERS, OnSelectLayer)
- ON_CBN_CLOSEUP (IDC_LAYERS, OnCloseUp )
- END_MESSAGE_MAP()
-
- int CKBANToolBar::OnCreate(LPCREATESTRUCT lpcs)
- {
- if(CToolBar::OnCreate(lpcs) == -1) {
- return -1;
- }
- if(!LoadToolBar(IDR_TOOLBAR)) {
- return -1;
- }
-
- CClientDC dc(this);
- int nHeight = -((dc.GetDeviceCaps(LOGPIXELSY) * 8) / 72);
- m_font.CreateFont(nHeight, 0, 0, 0, FW_NORMAL, 0, 0, 0,
- DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
- DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "MS Sans Serif"
- );
- CFont* pOldFont = dc.SelectObject(&m_font);
-
- TEXTMETRIC tm;
- dc.GetTextMetrics(&tm);
- int cxChar = tm.tmAveCharWidth;
- int cyChar = tm.tmHeight + tm.tmExternalLeading;
-
- dc.SelectObject(pOldFont);
-
- const int LayerPos = 17;
-
- // SetHeight(80 + 15 + 6);
- SetButtonInfo(LayerPos, IDC_LAYERS, TBBS_SEPARATOR, cxChar * 22);
-
- CRect rect;
- GetItemRect(LayerPos, &rect);
- rect.bottom = rect.top + cyChar * 16;
-
- if(!m_ctlLayerComboBox.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL |
- CBS_DROPDOWNLIST, rect, this, IDC_LAYERS)) {
- return -1;
- }
-
- m_ctlLayerComboBox.SetFont(&m_font);
-
- m_ctlLayerComboBox.AddString("Pattern Common");
- m_ctlLayerComboBox.AddString("Pattern Top");
- m_ctlLayerComboBox.AddString("Pattern Bottom");
- m_ctlLayerComboBox.AddString("Silk Top");
- m_ctlLayerComboBox.AddString("Silk Bottom");
-
- return 0;
- }
-
- void CKBANToolBar::OnSelectLayer(void)
- {
- int nIndex = m_ctlLayerComboBox.GetCurSel();
- CKBANView* pView = (CKBANView*)((CFrameWnd*)AfxGetMainWnd())->GetActiveView();
- switch(nIndex) {
- case 0 : pView->OnChangeLayer(ID_LAYER_PCOMMON); break;
- case 1 : pView->OnChangeLayer(ID_LAYER_PTOP ); break;
- case 2 : pView->OnChangeLayer(ID_LAYER_PBOTTOM); break;
- case 3 : pView->OnChangeLayer(ID_LAYER_STOP ); break;
- case 4 : pView->OnChangeLayer(ID_LAYER_SBOTTOM); break;
- }
- }
-
- void CKBANToolBar::OnCloseUp(void)
- {
- ((CFrameWnd*)AfxGetMainWnd())->GetActiveView()->SetFocus();
- }
-
- void CKBANToolBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHandler)
- {
- CToolBar::OnUpdateCmdUI(pTarget, bDisableIfNoHandler);
-
- CWnd* pWnd = GetFocus();
- if(pWnd != &m_ctlLayerComboBox) {
- CKBANView* pView = (CKBANView*)((CFrameWnd*)AfxGetMainWnd())->GetActiveView();
- KBAN_INFO& info = pView->GetDocument()->kban_info();
- uint layer = info.active_layer().get();
- m_ctlLayerComboBox.SetCurSel(layer);
- }
- }
-